package com.huirui.server.controller.mini.program;

import com.huirui.server.pojo.result.PageResult;
import com.huirui.server.pojo.result.Result;
import com.huirui.server.pojo.vo.SeckillProductVo;
import com.huirui.server.service.SeckillService;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/seckill")
@Slf4j
@Validated
@Tag(name = "秒杀管理", description = "微信小程序小程序秒杀相关API")
public class SeckillController {

    @Resource
    private SeckillService seckillService;

    @GetMapping("/list")
    public Result<PageResult<SeckillProductVo>> listSeckillProduct(
            @Parameter(
                    name = "type",  // 参数名（通常与 @RequestParam 一致）
                    description = "秒杀商品类型，例如：0-未开始，1-已开始",  // 参数描述
                    required = true,  // 是否必填（与 @RequestParam 的 required 保持一致）
                    example = "1"  // 示例值
            )
            @RequestParam("type") Integer type,
            @RequestParam("page") Integer page,
            @RequestParam("pageSize") Integer pageSize) {
        PageResult<SeckillProductVo> res = seckillService.listSeckillProduct(type, page, pageSize);
        return Result.success(res);
    }

}
